<?php 
 
 // This is the directory where images will be saved 
 $target = "C:\wamp\www\demo\images/"; 
 $target = $target . basename( $_FILES['photo']['name']); 
 
 // This gets all the other information from the form 
 $name=$_POST['name']; 
 $email=$_POST['email']; 
 $phone=$_POST['phone']; 
 $pic=($_FILES['photo']['name']); 
 
 // Connects to your Database 
 mysql_connect("localhost:3333", "test", "test") or die(mysql_error()) ; 
 mysql_select_db("test") or die(mysql_error()); 
 
 // Writes the information to the database 
 mysql_query("INSERT INTO students VALUES ('$name','$email','$phone','$pic',id)")  or die(mysql_error()) ; 
 
 // Writes the photo to the server 
 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
 { 
   // Tells you if its all ok 
   echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; 
 } 
 else { 
  // Gives and error if its not 
  echo "Sorry, there was a problem uploading your file."; 
 }
//Retrieves data from MySQL 
 $data = mysql_query("SELECT * FROM students") or die(mysql_error());  
 
 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { 
 
 //Outputs the image and other data
 Echo "<img src=http://localhost/demo/images/".$info['photo'] ."> <br>"; 
 Echo "<b>Name:</b> ".$info['name'] . "<br> "; 
 Echo "<b>Email:</b> ".$info['email'] . " <br>"; 
 Echo "<b>Phone:</b> ".$info['phone'] . " <hr>"; 
 }